package com.ruoyi.web.controller.bus;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bus.domain.WitChangeDriver;
import com.ruoyi.bus.service.IWitChangeDriverService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 更改司机记录表Controller
 * 
 * @author caiyanshan
 * @date 2021-07-27
 */
@RestController
@RequestMapping("/bus/record")
public class WitChangeDriverController extends BaseController
{
    @Autowired
    private IWitChangeDriverService witChangeDriverService;

    /**
     * 查询更改司机记录表列表
     */
    @PreAuthorize("@ss.hasPermi('bus:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(WitChangeDriver witChangeDriver)
    {
        startPage();
        List<WitChangeDriver> list = witChangeDriverService.selectWitChangeDriverList(witChangeDriver);
        return getDataTable(list);
    }

    /**
     * 导出更改司机记录表列表
     */
    @PreAuthorize("@ss.hasPermi('bus:record:export')")
    @Log(title = "更改司机记录表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WitChangeDriver witChangeDriver)
    {
        List<WitChangeDriver> list = witChangeDriverService.selectWitChangeDriverList(witChangeDriver);
        ExcelUtil<WitChangeDriver> util = new ExcelUtil<WitChangeDriver>(WitChangeDriver.class);
        return util.exportExcel(list, "record");
    }

    /**
     * 获取更改司机记录表详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:record:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(witChangeDriverService.selectWitChangeDriverById(recordId));
    }

    /**
     * 新增更改司机记录表
     */
    @PreAuthorize("@ss.hasPermi('bus:record:add')")
    @Log(title = "更改司机记录表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WitChangeDriver witChangeDriver)
    {
        return toAjax(witChangeDriverService.insertWitChangeDriver(witChangeDriver));
    }

    /**
     * 修改更改司机记录表
     */
    @PreAuthorize("@ss.hasPermi('bus:record:edit')")
    @Log(title = "更改司机记录表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WitChangeDriver witChangeDriver)
    {
        return toAjax(witChangeDriverService.updateWitChangeDriver(witChangeDriver));
    }

    /**
     * 删除更改司机记录表
     */
    @PreAuthorize("@ss.hasPermi('bus:record:remove')")
    @Log(title = "更改司机记录表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(witChangeDriverService.deleteWitChangeDriverByIds(recordIds));
    }
}
